From: Chao Peng Date: Tue, 7 Jul 2015 13:46:00 +0000 (+0200) Subject: x86: expose CBM length and COS number information X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2923 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=46af95231c9fa9db3363675dd15f7a42baf351c5;p=xen.git x86: expose CBM length and COS number information General CAT information such as maximum COS and CBM length are exposed to user space by a SYSCTL hypercall, to help user space to construct the CBM. Signed-off-by: Chao Peng Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 0be8b1b7c6..42f8c7ba45 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -15,6 +15,7 @@ */ #include #include +#include #include #include @@ -215,6 +216,33 @@ void psr_ctxt_switch_to(struct domain *d) psra->val = reg; } } +static struct psr_cat_socket_info *get_cat_socket_info(unsigned int socket) +{ + if ( !cat_socket_info ) + return ERR_PTR(-ENODEV); + + if ( socket >= nr_sockets ) + return ERR_PTR(-EBADSLT); + + if ( !test_bit(socket, cat_socket_enable) ) + return ERR_PTR(-ENOENT); + + return cat_socket_info + socket; +} + +int psr_get_cat_l3_info(unsigned int socket, uint32_t *cbm_len, + uint32_t *cos_max) +{ + struct psr_cat_socket_info *info = get_cat_socket_info(socket); + + if ( IS_ERR(info) ) + return PTR_ERR(info); + + *cbm_len = info->cbm_len; + *cos_max = info->cos_max; + + return 0; +} /* Called with domain lock held, no extra lock needed for 'psr_cos_ids' */ static void psr_free_cos(struct domain *d) diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 611a291fe2..f36b52fe5e 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -171,6 +171,24 @@ long arch_do_sysctl( break; + case XEN_SYSCTL_psr_cat_op: + switch ( sysctl->u.psr_cat_op.cmd ) + { + case XEN_SYSCTL_PSR_CAT_get_l3_info: + ret = psr_get_cat_l3_info(sysctl->u.psr_cat_op.target, + &sysctl->u.psr_cat_op.u.l3_info.cbm_len, + &sysctl->u.psr_cat_op.u.l3_info.cos_max); + + if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) + ret = -EFAULT; + + break; + default: + ret = -EOPNOTSUPP; + break; + } + break; + default: ret = -ENOSYS; break; diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 1023d5f7f6..d364e8c272 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -51,6 +51,9 @@ int psr_alloc_rmid(struct domain *d); void psr_free_rmid(struct domain *d); void psr_ctxt_switch_to(struct domain *d); +int psr_get_cat_l3_info(unsigned int socket, uint32_t *cbm_len, + uint32_t *cos_max); + int psr_domain_init(struct domain *d); void psr_domain_free(struct domain *d); diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 0cf9277c4a..cd544c0ef4 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -694,6 +694,20 @@ struct xen_sysctl_pcitopoinfo { typedef struct xen_sysctl_pcitopoinfo xen_sysctl_pcitopoinfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); +#define XEN_SYSCTL_PSR_CAT_get_l3_info 0 +struct xen_sysctl_psr_cat_op { + uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ + uint32_t target; /* IN */ + union { + struct { + uint32_t cbm_len; /* OUT: CBM length */ + uint32_t cos_max; /* OUT: Maximum COS */ + } l3_info; + } u; +}; +typedef struct xen_sysctl_psr_cat_op xen_sysctl_psr_cat_op_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_psr_cat_op_t); + struct xen_sysctl { uint32_t cmd; #define XEN_SYSCTL_readconsole 1 @@ -717,6 +731,7 @@ struct xen_sysctl { #define XEN_SYSCTL_coverage_op 20 #define XEN_SYSCTL_psr_cmt_op 21 #define XEN_SYSCTL_pcitopoinfo 22 +#define XEN_SYSCTL_psr_cat_op 23 uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ union { struct xen_sysctl_readconsole readconsole; @@ -740,6 +755,7 @@ struct xen_sysctl { struct xen_sysctl_scheduler_op scheduler_op; struct xen_sysctl_coverage_op coverage_op; struct xen_sysctl_psr_cmt_op psr_cmt_op; + struct xen_sysctl_psr_cat_op psr_cat_op; uint8_t pad[128]; } u; };